
// INCLUDES ********************************************************************

#import "GameController.h"


// CONSTANTS *******************************************************************

namespace 
{
    // singleton instance
    const GameController* sharedController = nil;
};

#pragma mark -
#pragma mark Private
// *****************************************************************************

@interface GameController ()

@property ( nonatomic, readwrite) BOOL mAnimating;

- ( void)udpate;

@end

// *****************************************************************************

@implementation GameController

@synthesize mAnimating;

// -----------------------------------------------------------------------------

+ ( id)sharedController
{
    if ( sharedController)
    {
        return sharedController;
    }
    
    sharedController = [[[GameController alloc] init] autorelease];
    
    return sharedController;
}

// -----------------------------------------------------------------------------

- ( void)initiateMainLoop
{
    Class displayLink = NSClassFromString(@"CADisplayLink");
    
    mDisplayLink = [displayLink displayLinkWithTarget:self 
                                             selector:@selector(update)
                    ];
    
    [mDisplayLink setFrameInterval:1.0f/60.0f];
    
    [mDisplayLink addToRunLoop:[NSRunLoop currentRunLoop] 
                       forMode:NSDefaultRunLoopMode
     ];
    
}

// -----------------------------------------------------------------------------

- ( void)udpate
{
    // main loop, from hereon c++ only
}

@end


/*

 // DisplayLink is available from iOS 3.1 on
 NSString* reqSysVer = @"3.1";
 
 NSString* currSysVer = [[UIDevice currentDevice] systemVersion];
 
 if ( [currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending)
 {
 mDisplayLinkSupported = YES;
 }
 




*/